<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/static/common/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="/static/common/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="/static/admin/css/admin.css"  media="all">
  <style type="text/css">

/* tooltip */
#tooltip{
  position:absolute;
  border:1px solid #ccc;
  background:#333;
  padding:2px;
  display:none;
  color:#fff;
}
</style>
</head>
<body style="padding:10px;">
  <div class="tplay-body-div">
    <div class="layui-tab">
      <ul class="layui-tab-title">
        <li class="layui-this">地区管理</li>
        <li><a href="{:url('admin/address/addEdit')}" class="a_menu">新增地区</a></li>
      </ul>
    </div> 
    <table class="layui-table" lay-size="sm">
      <colgroup>
        <col width="50">
        <col width="50">
        <col width="100">
        <col width="150">
        <col width="150">
        <col width="100">
      </colgroup>
      <thead>
        <tr>
          <th>首页图片</th>
          <th>头图</th>
          <th>地区</th>
          <th>国内/国外</th>
          <th>简介</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        {volist name="address" id="vo"}
        <tr>
          <td><a href="{$vo.pic|getUrl}" class="tooltip"><img src="{$vo.pic|getUrl}" width="20" height="20"></a></td>
          <td><a href="{$vo.toppic|getUrl}" class="tooltip"><img src="{$vo.toppic|getUrl}" width="20" height="20"></a></td>
          <td>{$vo.name}</td>
          <td>
            {if condition="$vo.type eq 1"}<span class="layui-badge layui-bg-orange">国内</span>{elseif condition="$vo.type eq 2"}<span class="layui-badge">国外</span>{/if}
          </td>
          <td>{$vo.desc}</td>
          <td class="operation-menu">
            <div class="layui-btn-group">
              <a href="{:url('admin/address/addEdit',['id'=>$vo.id])}" class="layui-btn layui-btn-xs a_menu layui-btn-primary" id="{$vo.id}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
              <a class="layui-btn layui-btn-xs layui-btn-primary delete" id="{$vo.id}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
            </div>
          </td>
        </tr>
        {/volist}
      </tbody>
    </table>
    <div style="padding:0 20px;">{$address->render()}</div>

    {include file="public/foot"}
    
    <script type="text/javascript">

    $('.delete').click(function(){
      var id = $(this).attr('id');
      layer.confirm('确定要删除?', function(index) {
        $.ajax({
          url:"{:url('admin/address/delete')}",
          data:{id:id},
          success:function(res) {
            layer.msg(res.msg);
            if(res.code == 1) {
              setTimeout(function(){
                location.href = res.url;
              },1500)
            }
          }
        })
      })
    })
    </script>
  </div>
</body>
</html>
